Goal : extract the same statistics as HexaLab to compare the computation of the Scaled Jacobian over the same hexahedral mesh
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import plotly.express as px
These files are generated with test_scaled_jacobian. See ../app/test_scaled_jacobian.cpp for more information
CSV_file = '../data/S1/SJ.csv'
df = pd.read_csv(CSV_file)
df.head(10)
| hex index | minSJ | |
|---|---|---|
| 0 | 0 | 0.999866 |
| 1 | 1 | 0.967752 |
| 2 | 2 | 0.845130 |
| 3 | 3 | 0.855850 |
| 4 | 4 | 0.613585 |
| 5 | 5 | 0.844899 |
| 6 | 6 | 0.641436 |
| 7 | 7 | 0.587914 |
| 8 | 8 | 0.695953 |
| 9 | 9 | 0.985510 |
print("Min = ",round(df['minSJ'].min(),3))
print("Max = ",round(df['minSJ'].max(),3))
print("Avg = ",round(df['minSJ'].mean(),3))
print("Var = ",round(df['minSJ'].var(),3))
Min = -0.492 Max = 1.0 Avg = 0.923 Var = 0.017
bins = pd.DataFrame()
bins['count'], bin_edges = np.histogram(df['minSJ'], bins=100, range=(0,1))
bins['value_min'] = bin_edges[:-1]
bins['value_avg'] = 0.5 * (bin_edges[:-1] + bin_edges[1:])
bins['value_max'] = bin_edges[1:]
bins
| count | value_min | value_avg | value_max | |
|---|---|---|---|---|
| 0 | 0 | 0.00 | 0.005 | 0.01 |
| 1 | 0 | 0.01 | 0.015 | 0.02 |
| 2 | 5 | 0.02 | 0.025 | 0.03 |
| 3 | 1 | 0.03 | 0.035 | 0.04 |
| 4 | 0 | 0.04 | 0.045 | 0.05 |
| ... | ... | ... | ... | ... |
| 95 | 293 | 0.95 | 0.955 | 0.96 |
| 96 | 373 | 0.96 | 0.965 | 0.97 |
| 97 | 487 | 0.97 | 0.975 | 0.98 |
| 98 | 786 | 0.98 | 0.985 | 0.99 |
| 99 | 4443 | 0.99 | 0.995 | 1.00 |
100 rows × 4 columns
How to use the same bins as HexaLab ?
also 100 bins but weird ticks values
#recomputing the histogram
#df['minSJ'].plot(kind='hist',bins=100, xticks=np.arange(0,1,0.1), xlim=(1,0), figsize=(16,8))
#using the bins dataframe
bins_sorted = bins.sort_values('value_avg',ascending=False)#eq to flip x axis
bins_sorted['value_avg'] = bins_sorted['value_avg'].round(3)
ax = bins_sorted.plot.bar(x='value_avg',y='count',figsize=(16,8),rot=90)
#remove some x labels
for i, t in enumerate(ax.get_xticklabels()):
if (i % 10) != 0:
t.set_visible(False)
#recomputing the histogram
#fig = px.histogram(df['minSJ'], nbins=100)
#using the bins dataframe
fig = px.bar(x=bins['value_avg'], y=bins['count'], labels={'x':'Scaled Jacobian', 'y':'count'})
fig.update_xaxes(range=[1, 0])#flip x axis
fig.show()